package com.rxw.nutmall.oss.config;

import com.rxw.nutmall.oss.utils.MinioUtil;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MinioConfig {
    private static NacosParameter parameter;
    @Autowired
    public void setParameter(NacosParameter parameter) {
        MinioConfig.parameter = parameter;
    }

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(parameter.getOssUrl())
                .credentials(parameter.getAccessKey(), parameter.getSecretKey())
                .build();
    }
}
